/**
 * @Title: HomeActivity.java
 * @Package com.sinoglobal.waitingMe.activity
 * @Description: TODO(用一句话描述该文件做什么)
 * @author hpq
 * @date 2015-8-30 上午11:55:09
 */

package com.sinoglobal.wallet.activity;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.alipay.sdk.app.PayTask;
import com.sinoglobal.wallet.R;
import com.sinoglobal.wallet.activity.W_RechargeDetailsActivity.DestoryRechargeDetailsReciver;
import com.sinoglobal.wallet.api.RemoteImpl;
import com.sinoglobal.wallet.app.SinoConstans;
import com.sinoglobal.wallet.entity.RsAplipay;
import com.sinoglobal.wallet.entity.RsUpay;
import com.sinoglobal.wallet.entity.RsWechat;
import com.sinoglobal.wallet.entity.W_AlipayEntiy;
import com.sinoglobal.wallet.entity.W_Bkjson;
import com.sinoglobal.wallet.entity.W_OrderStateEntiy;
import com.sinoglobal.wallet.entity.W_UpayEntiy;
import com.sinoglobal.wallet.entity.W_WechatEntiy;
import com.sinoglobal.wallet.task.MyAsyncTask;
import com.sinoglobal.wallet.util.ActivityUtil;
import com.sinoglobal.wallet.util.LogUtils;
import com.sinoglobal.wallet.util.NetWorkUtil;
import com.sinoglobal.wallet.util.PayResult;
import com.tencent.mm.sdk.constants.Build;
import com.tencent.mm.sdk.modelpay.PayReq;
import com.tencent.mm.sdk.openapi.IWXAPI;
import com.tencent.mm.sdk.openapi.WXAPIFactory;
import com.umpay.quickpay.UmpPayInfoBean;
import com.umpay.quickpay.UmpayQuickPay;
/**
 * @author clf
 * @createdate 2015-11-7
 * @Description: TODO(充值详情)
 */
public class W_RechargeRecordDetailsActivity extends W_SinoBaseActivity {
	private TextView recharge_details_time,recharge_state_txt,recharge_detail_record_money,recharge_detail_paystyle_recordname,recharge_details_orderno,recharge_state_notice,recharge_record_detail_commmit;
	int payStyle=0 ;
	private String payState;
	  private static final int SDK_PAY_FLAG = 1; //支付宝支付用的判断标记
		private MyHandler myHandler;//支付宝支付信息回调 使用静态内部类是防止内存泄露
		private String isRecharge="-1";//1,充值成功。0，充值失败。2待充值,3,提交成功
		private RsAplipay aplipay;//获取的支付订单对象
		private String Type="1";//充值界面跳转到充值详情的标示1是充值界面跳过去。2是充值记录界面跳过去
		private String money;
		private RsWechat wechat;
		private RsUpay upay;
		private String orderSn="";//订单号
		private String code="100";//判断返回的bkjosnz中的支付参数数据是否有效如果返回码是100说明数据有效，如果是101说明数据有问题需重新请求支付参数；

		/** 请求返回码 **/
		public static final int REQUESTCODE = 10;
		/** 优付支付成功 **/
		private static final String UMPAY_SUCCESS = "0000";
		/** 优付支付取消 **/
		private static final String UMPAY_CANCEL = "1001";
		private W_Bkjson bkjson;
		private IWXAPI api;
		private String source="";
		private DestoryRechargeRecordDetailsReciver destoryRechargeRecordDetailsReciver;//销毁W_RechargeRecordDetailsActivity的广播
		private class MyHandler extends Handler {


	        public void handleMessage(Message msg) {
	            switch (msg.what) {
	                case SDK_PAY_FLAG: {
	                    PayResult payResult = new PayResult((String) msg.obj);

	                    // 支付宝返回此次支付结果及加签，建议对支付宝签名信息拿签约时支付宝提供的公钥做验签
	                    String resultInfo = payResult.getResult();
	                    //支付状态
	                    String resultStatus = payResult.getResultStatus();
	                //	Toast.makeText(W_RechargelActivity.this, "支付宝返回码=="+resultStatus, 0).show();
	                    // 判断resultStatus 为“9000”则代表支付成功，具体状态码代表含义可参考接口文档
	                    if (TextUtils.equals(resultStatus, "9000")) {
	                       // notifyServer();通知故服务器支付成功
	                        showToast(getString(R.string.pay_success));
	                    	isRecharge="1";
	                    	  
	                    	
	                    	getOrderState(aplipay.getTrade_sn());	
	                    	break;
	                    }
	                    // 判断resultStatus 为非“9000”则代表可能支付失败
	                    // “8000”代表支付结果因为支付渠道原因或者系统原因还在等待支付结果确认，最终交易是否成功以服务端异步通知为准（小概率状态）
	                    else if (TextUtils.equals(resultStatus, "8000")) {
	                       // showToast(getString(R.string.pay_confirming));
	                      	isRecharge="3";
	            			
	                     
	                    } else if (TextUtils.equals(resultStatus, "6001")) {
	                     //   showToast(getString(R.string.pay_confirming));
	                      	isRecharge="2";
	                   
	            			
	                    } else if (TextUtils.equals(resultStatus, "6002")) {
	                       // showToast(getString(R.string.pay_confirming));
	                    	  
	                    	if("Record".equals(source)){
	        					sendDestoryRRDBroadcast();
	        				}
	                        Toast.makeText(W_RechargeRecordDetailsActivity.this, "网络状态不佳，请稍侯！", 0).show();
	                    	return;
	                    }else {
	                        // 其他值就可以判断为支付失败，包括用户主动取消支付，或者系统返回的错误
	                       showToast(getString(R.string.pay_fail));
	                    	isRecharge="0";
	                    	  
	                    	
	                    }
	                    if("Record".equals(source)){
        					sendDestoryRRDBroadcast();
        				}
	                    Bundle bundle = new Bundle();
	        			bundle.putString("isRecharge", isRecharge);
	        			bundle.putString("Money", money);
	        			bundle.putString("Source", source);//通知下个页面是从记录页面传过来的数据
	        			bundle.putSerializable("Sing", aplipay);//支付宝签名
	        			 bundle.putInt("payStyle", payStyle);
	        			goIntent(W_RechargeDetailsActivity.class, bundle); 	
	                    break;
	                }
	            }
	        }
	    }
	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		setContentView(R.layout.wallet_rechargerecord_detail_layout);
		mTemplateTitleText.setText("充值详情");
		initView();
	        source = getIntent().getStringExtra("Source");
	      //  LogUtils.v("111111111111-----------"+source);
		    payStyle = getIntent().getIntExtra("PayStyle", -1);
		   money = getIntent().getStringExtra("Money");
		   code = getIntent().getStringExtra("Code");
		   String Time = getIntent().getStringExtra("Time");
		    orderSn = getIntent().getStringExtra("OrderSn");
		   payState =getIntent().getStringExtra("PayState");
		   bkjson = (W_Bkjson) getIntent().getSerializableExtra("Bkjson");
		  if(money!=null){
		   float  moneyFouble= Float.valueOf(money);
		    recharge_detail_record_money.setText(String.format("%.2f", moneyFouble)+"元");}
				//从充值记录列表界面跳进来
				  recharge_details_time.setText(Time);
				  recharge_details_orderno.setText(orderSn);
				  setPayStyle();
				  setPayState();
				  
			}
   public void setPayStyle(){
	    if(payStyle==1){
			recharge_detail_paystyle_recordname.setText("余额");
		}else if(payStyle==2){
			aplipay=new RsAplipay();
			aplipay.setAppId(bkjson.getAppId());
			aplipay.setSeller(bkjson.getSeller());
			aplipay.setTrade_sn(bkjson.getTrade_sn());
			aplipay.setSign(bkjson.getSign());
			recharge_detail_paystyle_recordname.setText("支付宝");
		}else if(payStyle==3){
			upay= new RsUpay();
			upay.setMer_id(bkjson.getMer_id());
			upay.setTrade_no(bkjson.getTrade_no());
			upay.setTrade_sn(bkjson.getTrade_sn());
			recharge_detail_paystyle_recordname.setText("借记卡");
		}else if(payStyle==4){
					wechat= new RsWechat();
					wechat.setAppId(bkjson.getAppid());
					wechat.setNoncestr(bkjson.getNoncestr());
					wechat.setPartnerid(bkjson.getPartnerid());
					wechat.setPrepayid(bkjson.getPrepayid());
					wechat.setSign(bkjson.getSign());
					wechat.setTimestamp(bkjson.getTimestamp());
					wechat.setTrade_sn(bkjson.getTrade_sn());
			
		
			recharge_detail_paystyle_recordname.setText("微信");
		}		
	
   }  
   //支付状态:1:成功 2:失败 3:待支付 4:充值中、5已关闭
   public void setPayState(){
	   if("1".equals(payState)){
		   recharge_state_notice.setVisibility(View.GONE);
		   recharge_state_txt.setText("成功");
			recharge_record_detail_commmit.setText("完成");
		}else if("2".equals(payState)){
			 recharge_state_notice.setVisibility(View.GONE);
			recharge_state_txt.setText("失败");
			recharge_record_detail_commmit.setText("返回");
		}else if("3".equals(payState)){
			   recharge_state_notice.setVisibility(View.VISIBLE);
			recharge_state_txt.setText("待充值");
	if(payStyle==4){
		recharge_state_notice.setText("2小时未付款，将关闭此订单");
			}else{
				recharge_state_notice.setText("24小时未付款，将关闭此订单");
			}
			
			recharge_record_detail_commmit.setText("去支付");
		}else if("4".equals(payState)){
			 recharge_state_notice.setVisibility(View.VISIBLE);
			recharge_state_txt.setText("充值中");
			recharge_state_notice.setText("充值申请成功，将于2小时内到账");
				recharge_record_detail_commmit.setText("返回");
		}else if("5".equals(payState)){
			recharge_state_notice.setVisibility(View.GONE);
			recharge_state_txt.setText("已关闭");
		recharge_record_detail_commmit.setText("返回");
		}
	   
   }


	private void initView() {
	    myHandler=new MyHandler();
	    recharge_detail_record_money = findView(R.id.recharge_detail_record_money);//订单金额
		recharge_details_time = findView(R.id.recharge_details_time);//订单时间
		recharge_state_txt = findView(R.id.recharge_state_txt);//订单状态
		recharge_details_orderno = findView(R.id.recharge_details_orderno);//订单编号
		recharge_state_notice = findView(R.id.recharge_state_notice);//订单底部提示语
		recharge_record_detail_commmit = findView(R.id.recharge_record_detail_commmit);
		recharge_detail_paystyle_recordname = findView(R.id.recharge_detail_paystyle_recordname);//支付方式名字
		recharge_record_detail_commmit.setOnClickListener(this);
		api = WXAPIFactory.createWXAPI(this, null);
		// 将该app注册到微信
		api.registerApp(SinoConstans.APP_WeCHATID);
		initReciver();
	}
	private void initReciver() {
		// TODO Auto-generated method stub
		IntentFilter intentFilter = new IntentFilter();
		intentFilter.addAction(SinoConstans.KEY_DestoryReceiverTwo);
		destoryRechargeRecordDetailsReciver = new DestoryRechargeRecordDetailsReciver();
		registerReceiver(destoryRechargeRecordDetailsReciver, intentFilter);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		int id = v.getId();
		if(id==R.id.recharge_record_detail_commmit){
			if(recharge_record_detail_commmit.getText().equals("完成")){
			finish();}
			if(recharge_record_detail_commmit.getText().equals("重试")){
				if(payStyle==2){//支付宝支付
					if("100".equals(code)){
					pay(aplipay.getSign());
					}else {
						getAlipayData();
					}
				}else if(payStyle==3){//U付,借记卡支付	
					
					if("100".equals(code)){
						doUmpay(upay.getTrade_no());
						}else {
							getUpayData();
						}
				}else if(payStyle==4){//微信支付
					boolean isPaySupported = api.getWXAppSupportAPI() >= Build.PAY_SUPPORTED_SDK_INT;
					
					if(ActivityUtil.checkApkExist(this,"com.tencent.mm")){
						if(isPaySupported){
							if("100".equals(code)){
								PayReq req = new PayReq();
								req.appId			= wechat.getAppId();
								req.partnerId		= wechat.getPartnerid();
								req.prepayId		= wechat.getPrepayid();
								req.nonceStr		= wechat.getNoncestr();
								req.timeStamp		= wechat.getTimestamp();
								req.packageValue	="Sign=WXPay";
								 req.sign			= wechat.getSign();
								//LogUtils.v("appId=="+	req.appId+"partnerId=="+req.partnerId+"prepayId=="+req.prepayId+"nonceStr=="+req.nonceStr+"timeStamp=="+req.timeStamp+"packageValue=="+req.packageValue+"sign==="+req.sign	);
								// 在支付之前，如果应用没有注册到微信，应该先调用IWXMsg.registerApp将应用注册到微信
								api.sendReq(req);
								sendWeChatBroadcast(wechat,money,"wallet");//将数据传到微信的回调页面WXPayEntryActivity
								}else {
									getWechatData();	
								}
						
						}else{
							Toast.makeText(this, "当前微信版本不支持支付！", 0).show();
						}
					
					}else{
						Toast.makeText(this, "请先安装微信！", 0).show();
					}
				
				}
		}
			if(recharge_record_detail_commmit.getText().equals("去支付")){
				if(payStyle==2){//支付宝支付
					if("100".equals(code)){
						pay(aplipay.getSign());
						}else {
							getAlipayData();;
						}
				}else if(payStyle==3){//U付,借记卡支付	
					if("100".equals(code)){
						doUmpay(upay.getTrade_no());
						}else {
							getUpayData();
						}
				
				}else if(payStyle==4){//微信支付
boolean isPaySupported = api.getWXAppSupportAPI() >= Build.PAY_SUPPORTED_SDK_INT;
					
					if(ActivityUtil.checkApkExist(this,"com.tencent.mm")){
						if(isPaySupported){
							if("100".equals(code)){
								PayReq req = new PayReq();
								req.appId			= wechat.getAppId();
								req.partnerId		= wechat.getPartnerid();
								req.prepayId		= wechat.getPrepayid();
								req.nonceStr		= wechat.getNoncestr();
								req.timeStamp		= wechat.getTimestamp();
								req.packageValue	="Sign=WXPay";
								 req.sign			= wechat.getSign();
								//LogUtils.v("appId=="+	req.appId+"partnerId=="+req.partnerId+"prepayId=="+req.prepayId+"nonceStr=="+req.nonceStr+"timeStamp=="+req.timeStamp+"packageValue=="+req.packageValue+"sign==="+req.sign	);
							
								// 在支付之前，如果应用没有注册到微信，应该先调用IWXMsg.registerApp将应用注册到微信
								api.sendReq(req);
								sendWeChatBroadcast(wechat,money,"wallet");//将数据传到微信的回调页面WXPayEntryActivity
		                      // LogUtils.v("充值详情---11110-0-"+wechat.getAppId()+"qian--"+money);     
								}else {
									getWechatData();	  
								}
											
						}else{
							Toast.makeText(this, "当前微信版本不支持支付！", 0).show();
						}
					
					}else{
						Toast.makeText(this, "请先安装微信！", 0).show();
					}
				}
				}
			if(recharge_record_detail_commmit.getText().equals("返回")){
				finish();
				}else if (id == R.id.wallet_noData) {
					 if(NetWorkUtil.getNetWorkInfoType(getApplicationContext())==NetWorkUtil.NONE){
							showToast("请检查网络是否连接！");	
							 loadError(true);
							}else{
								loadError(false);;
							}
				}
		}
	}
	/**
	 * 向微信回调页面传递微信支付参数数据
	 * @param rs
	 * @param str
	 */
	private void sendWeChatBroadcast(RsWechat rs,String str,String type) {
		Intent intent = new Intent();
		intent.setAction(SinoConstans.KEY_WechatReceiver);
		intent.putExtra("WeChat",rs);
		intent.putExtra("Money",str);
		intent.putExtra("Type",type);
		intent.putExtra("Source",source);//记录是从充值记录页面传的数据
		sendBroadcast(intent);
	}
	private void getAlipayData() {
		MyAsyncTask<W_AlipayEntiy> task = new MyAsyncTask<W_AlipayEntiy>(true,this,true) {
			@Override
			public W_AlipayEntiy before(Void... params) throws Exception {
				// TODO 测试接口
				return RemoteImpl.getInstance().getAlipay(W_RechargeRecordDetailsActivity.this,orderSn, money, "钱包充值", "钱包", "1", "wallet");
			}

			@Override
			public void after(W_AlipayEntiy result) {
				if (result != null) {
					if (result.getCode().equals("100")) {
					aplipay=result.getRs();
					pay(aplipay.getSign());
					}else{
						Toast.makeText(W_RechargeRecordDetailsActivity.this, result.getMsg(), 0).show();
					}
				}

			}

			@Override
			public void exception() {
			}
		};
		task.execute();
	}
	private void getUpayData() {
		MyAsyncTask<W_UpayEntiy> task = new MyAsyncTask<W_UpayEntiy>(true,this,true) {
			@Override
			public W_UpayEntiy before(Void... params) throws Exception {
				// TODO 测试接口
				return RemoteImpl.getInstance().getUpay(W_RechargeRecordDetailsActivity.this, orderSn,money, "钱包充值", "钱包", "1", "wallet");
			}
			
			@Override
			public void after(W_UpayEntiy result) {
				if (result != null) {
					if (result.getCode().equals("100")) {
						upay=result.getRs();
						//LogUtils.v("rs.getTrade_no()===="+	upay.getTrade_no());
						doUmpay(upay.getTrade_no());
					}else{
						Toast.makeText(W_RechargeRecordDetailsActivity.this, result.getMsg(), 0).show();
					}
				}
				
			}
			
			@Override
			public void exception() {
			}
		};
		task.execute();
	}
	private void getWechatData() {
		MyAsyncTask<W_WechatEntiy> task = new MyAsyncTask<W_WechatEntiy>(true,this,true) {
			@Override
			public W_WechatEntiy before(Void... params) throws Exception {
				// TODO 测试接口
				return RemoteImpl.getInstance().getWeChat(W_RechargeRecordDetailsActivity.this, orderSn, money, "钱包充值", "钱包", "1", "wallet");
			}
			
			@Override
			public void after(W_WechatEntiy result) {
				if (result != null) {
					if (result.getCode().equals("100")) {
							RsWechat wechat=result.getRs();
							PayReq req = new PayReq();
							req.appId			= wechat.getAppId();
							req.partnerId		= wechat.getPartnerid();
							req.prepayId		= wechat.getPrepayid();
							req.nonceStr		= wechat.getNoncestr();
							req.timeStamp		= wechat.getTimestamp();
							req.packageValue	="Sign=WXPay";
							 req.sign			= wechat.getSign();
							//LogUtils.v("appId=="+	req.appId+"partnerId=="+req.partnerId+"prepayId=="+req.prepayId+"nonceStr=="+req.nonceStr+"timeStamp=="+req.timeStamp+"packageValue=="+req.packageValue+"sign==="+req.sign	);
						
							// 在支付之前，如果应用没有注册到微信，应该先调用IWXMsg.registerApp将应用注册到微信
							api.sendReq(req);
							/*if(api.sendReq(req)){
								Toast.makeText(W_RechargelActivity.this, "正常调起支付"+api.sendReq(req), Toast.LENGTH_SHORT).show();
							}*/
							sendWeChatBroadcast(wechat,money,"wallet");//传到微信的回调页面WXPayEntryActivity
					}else{
						Toast.makeText(W_RechargeRecordDetailsActivity.this, result.getMsg(), 0).show();
					}
				}
				
			}
			
			@Override
			public void exception() {
			}
		};
		task.execute();
	}
	  /**
     * U付支付
     *
     * @param tradeNo 封装数据
     */
    private void doUmpay(String tradeNo) {
        UmpayQuickPay.requestPayWithBind(this, tradeNo, null, "0", null, new UmpPayInfoBean(), REQUESTCODE);//借记卡支付
    }
	public void pay(final String orderInfo) {
		Runnable payRunnable = new Runnable() {
			@Override
			public void run() {
				// 构造PayTask 对象
				PayTask alipay = new PayTask(W_RechargeRecordDetailsActivity.this);
				// 调用支付接口
				String result = alipay.pay(orderInfo);
				Message msg = new Message();
				msg.what = SDK_PAY_FLAG;
				msg.obj = result;
				myHandler.sendMessage(msg);
			}
		};
		   // 必须异步调用
        Thread payThread = new Thread(payRunnable);
        payThread.start();

		 
	}
	/**
	 * 3.U付在这里接收并处理支付结果
	 * 
	 * @param requestCode
	 *            支付请求码
	 * @param resultCode
	 *            SDK固定返回88888
	 * @param data
	 *            支付结果和结果描述信息
	 * @author niexuyang 2012-8-20
	 */
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		if (requestCode == REQUESTCODE) {
			String umpresultCode = data.getStringExtra("umpResultCode");
			if (UMPAY_SUCCESS.equals(umpresultCode)) {
				showToast("支付成功");
				isRecharge="1";
				if("Record".equals(source)){
					sendDestoryRRDBroadcast();
				}
				getOrderState(upay.getTrade_sn());	
            	
			} else if (UMPAY_CANCEL.equals(umpresultCode)) {
				showToast("取消支付");
				isRecharge="2";
				//LogUtils.v("2222umpresultCode--"+umpresultCode);
				if("Record".equals(source)){
					sendDestoryRRDBroadcast();
				}
				  Bundle bundle = new Bundle();
      			bundle.putString("isRecharge", isRecharge);
      			bundle.putString("Money", money);
      			bundle.putString("Source", source);//通知下个页面是从记录页面传过来的数据
      			bundle.putSerializable("Upay", upay);//U付订单对象
      			 bundle.putInt("payStyle", payStyle);
      			goIntent(W_RechargeDetailsActivity.class, bundle); 	
      			finish();
			} else {
				showToast("支付失败");
				isRecharge="0";
				if("Record".equals(source)){
					sendDestoryRRDBroadcast();
				}
				  Bundle bundle = new Bundle();
      			bundle.putString("isRecharge", isRecharge);
      			bundle.putString("Money", money);
      			bundle.putString("Source", source);//通知下个页面是从记录页面传过来的数据
      			bundle.putSerializable("Upay", upay);//U付订单对象
      			 bundle.putInt("payStyle", payStyle);
      			goIntent(W_RechargeDetailsActivity.class, bundle); 	
      			finish();
			}
			super.onActivityResult(requestCode, resultCode, data);
		}
	}
	private void getOrderState(final String orderSn) {
		MyAsyncTask<W_OrderStateEntiy> task = new MyAsyncTask<W_OrderStateEntiy>(true,this,true) {
			@Override
			public W_OrderStateEntiy before(Void... params) throws Exception {
				// TODO 测试接口
				return RemoteImpl.getInstance().getOrderState(W_RechargeRecordDetailsActivity.this,orderSn);
			}
			
			@Override
			public void after(W_OrderStateEntiy result) {
				if (result != null) {
					if (result.getCode().equals("100")) {
						 String  orderState=result.getRs();
						 if("3".equals(orderState)){//支付订单状态1：支付中、2：已回调、3：支付成功、4：异常订单
								isRecharge="1";
						  }else {
								isRecharge="3";
						  }
						 if("Record".equals(source)){
	        					sendDestoryRRDBroadcast();
	        				}
						 Bundle bundle = new Bundle();
		        			bundle.putString("isRecharge", isRecharge);
		        			bundle.putString("Source", source);//通知下个页面是从记录页面传过来的数据
		        			bundle.putString("Money", money);
		        			 bundle.putInt("payStyle", payStyle);
		        			 bundle.putSerializable("Sing", aplipay);//支付宝签名
		        			 bundle.putSerializable("Upay", upay);//支付宝签名
		        			goIntent(W_RechargeDetailsActivity.class, bundle);
					}else{
						if("Record".equals(source)){
        					sendDestoryRRDBroadcast();
        				}
						Toast.makeText(W_RechargeRecordDetailsActivity.this, result.getMsg(), 0).show();
						 Bundle bundle = new Bundle();
		        			bundle.putString("isRecharge", isRecharge);
		        			bundle.putString("Money", money);
		        			bundle.putString("Source", source);//通知下个页面是从记录页面传过来的数据
		        			//LogUtils.v("23333333222222222-----------"+source);
		        			 bundle.putInt("payStyle", payStyle);
		        			 bundle.putSerializable("Sing", aplipay);//支付宝签名
		        			 bundle.putSerializable("Upay", upay);//支付宝签名
		        			goIntent(W_RechargeDetailsActivity.class, bundle);
					}
				}
				
			}
			
			@Override
			public void exception() {
			}
		};
		task.execute();
	}
	private void sendDestoryRRDBroadcast() {//发送销毁W_RechargeRecordDetailsActivity的广播
		Intent intent = new Intent();
		intent.setAction(SinoConstans.KEY_DestoryReceiverTwo);
		sendBroadcast(intent);
	}
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		unregisterReceiver(destoryRechargeRecordDetailsReciver);//充值详情的广播取消
		  if (myHandler != null) { //退出时清空handler所有队列信息,以防内存泄露
	            myHandler.removeCallbacksAndMessages(null);
	        }
	}
	public  class DestoryRechargeRecordDetailsReciver extends BroadcastReceiver {


		public  DestoryRechargeRecordDetailsReciver(){

		}

		@Override
		public void onReceive(Context context, Intent intent) {
			if(intent.getAction().equals(SinoConstans.KEY_DestoryReceiverTwo)){
				W_RechargeRecordDetailsActivity.this.finish();
			//	LogUtils.v("DestoryRechargeDetailsReciver-----");
			}

		}
	}
}
